var { mysql } = require('../qcloud')

// 新增用户信息接口
module.exports = async (ctx, next) => {
    let { cid, openid, cname, officeid, groupid } = ((ctx.request || {}).body || {})
    try {
        let res = await mysql('cMemberInfo').insert({
            cid,
            openid,
            cname,
            officeid,
            groupid
        })
        if (res[0] !== undefined) {
            ctx.state.data = 'success'
            ctx.state.code = 200
        } else {
            ctx.state.data = 'insert fail'
            ctx.state.code = 204
        }
    } catch (error) {
        ctx.state.data = error
        ctx.state.code = 409
    }
}
